<!DOCTYPE html>
<html lang="en">
<head>
    <meta name="description" content="后台管理">
    <!-- Twitter meta-->
    <title>回收帖子</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- Main CSS-->
    <link rel="stylesheet" type="text/css" href="../../public/admin/css/main.css">
    <!-- Font-icon css-->
    <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
    <style>
        body{overflow-x:hidden; background:#f2f0f5; padding:15px 0px 10px 5px;}
        #searchmain{ font-size:12px;}
        #search{ font-size:12px; background:#548fc9; margin:10px 10px 0 0; display:inline; width:100%; color:#FFF}
        #search form span{height:40px; line-height:40px; padding:0 0px 0 10px; float:left;}
        #search form input.text-word{height:24px; line-height:24px; width:180px; margin:8px 0 6px 0; padding:0 0px 0 10px; float:left; border:1px solid #FFF;}


        #search a:hover.add{ text-decoration:underline; color:#d2e9ff;}
        #main-tab{ border:1px solid #eaeaea; background:#FFF; font-size:12px;}

        #main-tab td{ font-size:12px; line-height:40px;}
        #main-tab td a{ font-size:12px; color:#548fc9;}
        #main-tab td a:hover{color:#565656; text-decoration:underline;}
        .bordertop{ border-top:1px solid #ebebeb}
        .borderright{ border-right:1px solid #ebebeb}
        .borderbottom{ border-bottom:1px solid #ebebeb}
        .borderleft{ border-left:1px solid #ebebeb}
        .gray{ color:#dbdbdb;}
        td.fenye{ padding:10px 0 0 0; text-align:right;}
        .bggray{ background:#f9f9f9; font-size:14px; font-weight:bold; padding:10px 10px 10px 0; width:120px;}
        .main-for{ padding:10px;}
        .main-for input.text-word{ width:310px; height:36px; line-height:36px; border:#ebebeb 1px solid; background:#FFF; font-family:"Microsoft YaHei","Tahoma","Arial",'宋体'; padding:0 10px;}
        .main-for select{ width:310px; height:36px; line-height:36px; border:#ebebeb 1px solid; background:#FFF; font-family:"Microsoft YaHei","Tahoma","Arial",'宋体'; color:#666;}
        .main-for input.text-but{ width:100px; height:40px; line-height:30px; border: 1px solid #cdcdcd; background:#e6e6e6; font-family:"Microsoft YaHei","Tahoma","Arial",'宋体'; color:#969696; float:left; margin:0 10px 0 0; display:inline; cursor:pointer; font-size:14px; font-weight:bold;}
        td{ background:#fcf8e3; line-height: 50px }
        .success{ background: #bee5eb;}
    </style>
</head>
<body class="app sidebar-mini rtl">
<?php if(!empty($_COOKIE['uname']) && !empty($_COOKIE['auth'])) { ?>
    <?php require 'menu.php'?>

    <!-- Sidebar menu-->
    <main class="app-content">
        <div class="app-title">
            <div>
                <h1><i class="fa fa-dashboard"></i> 首页</h1>
            </div>
            <ul class="app-breadcrumb breadcrumb">
                <li class="breadcrumb-item"><i class="fa fa-home fa-lg"></i></li>
                <li class="breadcrumb-item"><a href="../admin.php">首页</a></li>
            </ul>
        </div>
        <div class="list-group-item active" style="margin-bottom: 10px;line-height: 20px">
            <form method="post" action='contro_post.php?a=del_search' style="">
                <span>帖子：</span>
                <input style="color: #000; " type="text" name="title" value="<?php echo @$_GET['search'] ?>"
                       class="text-word">
                <input type="submit" value="查询" class="text-but">
            </form>

        </div>
        <table class="table table-bordered">

            <thead>
            <tr align="center" style="background: #fff">
                <th>
                    id
                </th>
                <th>
                    主题
                </th>
                <th>
                    发帖人
                </th>
                <th>
                    发表时间
                </th>
                <th>
                    状态
                </th>
                <th>
                    操作
                </th>

            </tr>
            </thead>
            <?php
            require 'config.php';
            $auth = $_COOKIE['auth'];
            if (!empty($_GET['search'])) {

                $search = $_GET['search'];
                $sql = "select user.userName,post.id,post.title,post.ctime,post.elite,post.top,user.id as userid from user,post where user.id=post.uid and post.recycle = 1 and title like '%{$search}%'";
                $result = mysqli_query($link, $sql);
                //查询所有的数据总条数；
                $num_All = mysqli_num_rows($result);
                //分页几条；
                $page = 4;
                //分几页,总页数；
                $page_All = ceil($num_All / $page);
                //判断p是否有值；
                if (empty($_GET['p'])) {
                    $p = 1;
                } else {
                    $p = $_GET['p'];
                }
                $page_num = ($p - 1) * $page;
                $sql = "select user.userName,post.id,post.title,post.ctime,post.elite,post.top,user.id as userid from user,post where user.id=post.uid and post.recycle = 1 and title like '%{$search}%' limit {$page_num},{$page}";
                $result = mysqli_query($link, $sql);
                $num = ($p-1)*$page;
                while ($rows = mysqli_fetch_assoc($result)) {
                    $pid = $rows['id'];
                    $userid = $rows['userid'];
                    $title = $rows['title'];
                    $time = date('Y-m-d',$rows['ctime']);
                    echo "<tr align='center' class='info'>";
                    echo "<td class='danger'>{$rows['id']}</td>";
                    echo "<td class='danger'>{$title} </td>";
                    echo "<td class='danger'>{$rows['userName']}</td>";
                    echo "<td class='danger'>{$time}</td>";
                    if ($rows['elite'] == '0' && $rows['top'] == '0') {
                        echo "<td>普通</td>";
                    } elseif ($rows['elite'] == '1') {
                        if ($rows['top'] == '1') {
                            echo "<td>置顶并加精</td>";
                        } else {
                            echo "<td>加精</td>";
                        }
                    } elseif ($rows['top'] == '1') {
                        if ($rows['elite'] == '1') {
                            echo "<td>置顶并加精</td>";
                        } else {
                            echo "<td>置顶</td>";
                        }
                    }
                    echo "<td class='danger'>";
                    if ($auth == '管理员'){
                        echo "<a href='contro_post.php?a=reply&title=$title&p=$p'>恢复</a>&nbsp;&nbsp;
                          <a onclick=\"jquery:alert('你目前没有权限')\">删除</a> ";
                    }else{
                        echo "<a href='contro_post.php?a=reply&title=$title&p=$p'>恢复</a>&nbsp;&nbsp;
                          <a href='contro_post.php?a=del&title=$title&p=$p'>删除</a> ";
                    }
                    echo "</td>";
                    echo "</tr>";
                }
            }else{
                $sql = "select user.userName,post.id,post.title,post.ctime,post.elite,post.top,user.id as userid from user,post where user.id=post.uid and post.recycle = 1";
                $result = mysqli_query($link, $sql);
                //查询所有的数据总条数；
                $num_All = mysqli_num_rows($result);
                //分页几条；
                $page = 4;
                //分几页,总页数；
                $page_All = ceil($num_All / $page);
                //判断p是否有值；
                if (empty($_GET['p'])) {
                    $p = 1;
                } else {
                    $p = $_GET['p'];
                }
                $page_num = ($p - 1) * $page;
                $sql = "select user.userName,post.id,post.title,post.ctime,post.elite,post.top,user.id as userid from user,post where user.id=post.uid and post.recycle = 1 limit {$page_num},{$page}";
                $result = mysqli_query($link, $sql);
                $num = ($p-1)*$page;
                while ($rows = mysqli_fetch_assoc($result)) {
                    $pid = $rows['id'];
                    $userid = $rows['userid'];
                    $title = $rows['title'];
                    $time = date('Y-m-d',$rows['ctime']);
                    echo "<tr align='center' class='info'>";
                    echo "<td class='danger'>{$rows['id']}</td>";
                    echo "<td class='danger'>{$title} </td>";
                    echo "<td class='danger'>{$rows['userName']}</td>";
                    echo "<td class='danger'>{$time}</td>";
                    if ($rows['elite'] == '0' && $rows['top'] == '0') {
                        echo "<td>普通</td>";
                    } elseif ($rows['elite'] == '1') {
                        if ($rows['top'] == '1') {
                            echo "<td>置顶并加精</td>";
                        } else {
                            echo "<td>加精</td>";
                        }
                    } elseif ($rows['top'] == '1') {
                        if ($rows['elite'] == '1') {
                            echo "<td>置顶并加精</td>";
                        } else {
                            echo "<td>置顶</td>";
                        }
                    }
                    echo "<td class='danger'>";
                    /*  <a onclick='member_add('查看帖子','post_list.php?title={$title}&id=$pid','900','500')'>查看帖子</a>&nbsp;&nbsp;*/

                    if ($auth == '管理员'){
                        echo "<a href='contro_post.php?a=reply&title=$title&p=$p'>恢复</a>&nbsp;&nbsp;
                          <a onclick=\"jquery:alert('你目前没有权限')\">删除</a> ";
                    }else{
                        echo "<a href='contro_post.php?a=reply&title=$title&p=$p'>恢复</a>&nbsp;&nbsp;
                          <a href='contro_post.php?a=del&title=$title&p=$p'>删除</a> ";
                    }
                    echo "</td>";
                    echo "</tr>";
                }
            }
            ?>
        </table>
        <div class="page" style="text-align: right">
            当前<?php echo $p;?>/<?php echo $page_All;?>页 总条数：<?php echo $num_All;?>条&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <a href="./post.php?p=1&search=<?php echo @$search?>">首页</a>&nbsp;&nbsp;&nbsp;
            <a href="./post.php?p=<?php echo $p<=1?1:($p-1)?>&search=<?php echo @$search?>">上一页</a>&nbsp;&nbsp;&nbsp;
            <a href="./post.php?p=<?php echo $p>=$page_All?$page_All:($p+1)?>&search=<?php echo @$search?>">下一页</a>&nbsp;&nbsp;&nbsp;
            <a href="./post.php?p=<?php echo $page_All;?>&search=<?php echo @$search?>">尾页</a>&nbsp;&nbsp;&nbsp;
        </div>
    </main>

    <script src="../../public/admin/js/jquery-3.2.1.min.js"></script>
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script type="text/javascript" src="https://cdn.bootcss.com/Swiper/3.4.2/js/swiper.jquery.min.js"></script>
    <script src="../../public/admin/js/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="../../public/admin/js/xadmin.js"></script>
    <script src="../../public/admin/js/popper.min.js"></script>
    <script src="../../public/admin/js/bootstrap.min.js"></script>
    <script src="../../public/admin/js/main.js"></script>
    <script src="../../public/admin/js/plugins/pace.min.js"></script>
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script type="text/javascript" src="https://cdn.bootcss.com/Swiper/3.4.2/js/swiper.jquery.min.js"></script>
    <script src="../../public/admin/js/lib/layui/layui.js" charset="utf-8"></script>
    <?php
}else{
    echo "<script>alert('你还没登录');window.location.href='../index.php';</script>";die;
}
?>
<script>
    function x_admin_show(title,url,w,h){
        if (title == null || title == '') {
            title=false;
        };
        if (url == null || url == '') {
            url="404.html";
        };
        if (w == null || w == '') {
            w=800;
        };
        if (h == null || h == '') {
            h=($(window).height() - 50);
        };
        layer.open({
            type: 2,
            area: [w+'px', h +'px'],
            fix: false, //不固定
            maxmin: true,
            shadeClose: true,
            shade:0.4,
            title: title,
            content: url
        });
    }
    function member_add(title,url,w,h){
        x_admin_show(title,url,w,h);
    }
</script>
</body>
</html>
